package com.example.dynamicdatasourcetest.service.impl;

import com.example.dynamicdatasourcetest.annotation.DataSource;
import com.example.dynamicdatasourcetest.bean.User;
import com.example.dynamicdatasourcetest.datasource.DataSourceConst;
import com.example.dynamicdatasourcetest.mapper.UserMapper;
import com.example.dynamicdatasourcetest.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@DataSource(DataSourceConst.DEFAULT_DATASOURCE)
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    @DataSource(DataSourceConst.DATASOURCE_TEST2)
    public List<User> list() {
        return userMapper.selectAll();
    }
}
